package lab_14.com.acme.bankapp.service.bank;

import lab_14.com.acme.bankapp.domain.bank.*;
import lab_14.com.acme.bankapp.domain.bank.Exceptions.ClientExistsException;
import lab_14.com.acme.bankapp.domain.bank.Exceptions.DataFileLoadingException;

public class BankService {

	public static Client addClient(Bank bank, Client client) throws ClientExistsException, DataFileLoadingException {

		// According to the task, we should save bank state after each
		// BankService's method invocation.
		bank.addClient(client);
		BankDataLoaderService.serializeBankToFile(bank, BankApplication.OUT_SERIALIZE_NAME);
		return client;
	}

	public static Account addAccount(Bank bank, Client client, Account account)
			throws DataFileLoadingException {
		client.addClientAccount(account);
		BankDataLoaderService.serializeBankToFile(bank, BankApplication.OUT_SERIALIZE_NAME);
		return account;
	}

}